#include "header.h"
typedef struct car
{
    char name[20];
    int price;
}car_t;
int main(int argc,char const *argv[])
{
   char *str = "Hello World";
   int fd = open("stu.dat",O_RDWR|O_CREAT|O_APPEND,0666);
   if(fd < 0 )
   {
       printf("errno:%d errinfo:%s\n",errno,strerror(errno));
       return -1;
   }
   printf("创建文件成功:%d\n",fd);
   int len = write(fd,str,strlen(str));
   printf("写入文件成功:%d\n",len);


   int num = 100;
   len = write(fd,&num,sizeof(num));
   printf("写入文件成功:%d\n",len);

   char a = '\n';
   write(fd,&a,sizeof(a));
   car_t car1 = {"BMW",1000000};
   len = write(fd,&car1,sizeof(car1));
   printf("写入文件成功:%d\n",len);
   close(fd);
    return 0;
}
